package com.winit.openapi.ups.controller;

import java.util.List;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

import com.alibaba.fastjson.JSON;
import com.winit.common.spi.context.CommandContext;
import com.winit.openapi.controller.BaseController;
import com.winit.openapi.model.RequestMsg;
import com.winit.openapi.model.ResponseMsg;
import com.winit.ups.spi.basicdata.BasicDataService;
import com.winit.ups.spi.basicdata.command.GetBasicDataListCommand;
import com.winit.ups.spi.basicdata.vo.BasicData;


/**
 * ups  basic Data Controller
 * @author qibin.tang
 *
 */
@Controller
@RequestMapping(value = "/ups/basicData")
public class UpsBasicDataController extends BaseController{
    
    private Logger  logger = LoggerFactory.getLogger(UpsBasicDataController.class);
    
    @Resource
    private BasicDataService upsBasicDataService;
    
    /**
     * 获取区域配置
     * @param requestMsg
     * @param responseMsg
     * @return
     */
    @RequestMapping(value = "/queryUpsRegionConfig")
    public String queryUpsRegionConfig(@ModelAttribute RequestMsg requestMsg, @ModelAttribute ResponseMsg responseMsg) {
    	GetBasicDataListCommand command = JSON.parseObject(requestMsg.getData().toString(), GetBasicDataListCommand.class);
        command.setCtx(CommandContext.getContext());
        List<BasicData> list = upsBasicDataService.getBasicDataList(command);
        logger.info("UpsBasicDataController.queryUpsRegionConfig:"+JSON.toJSONString(list));
        responseMsg.setData(list);
        return SUCCESS;
    }

}
